import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import { App } from 'vue';

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "login" */ '../views/login/LoginView.vue')
  },
  {
    path: '/home',
    name: 'Home',
    redirect: '/home/dashboard',
    component: () => import(/* webpackChunkName: "home" */ '../layouts/defaultView.vue'),
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import(/* webpackChunkName: "dashboard" */ '../views/dashboard/indexView.vue')
      },
      {
        path: 'users',
        name: 'Users',
        component: () => import(/* webpackChunkName: "users" */ '../views/users/indexView.vue')
      },
      {
        path: 'menus',
        name: 'Menus',
        component: () => import(/* webpackChunkName: "menus" */ '../views/menus/indexView.vue')
      },
      {
        path: 'roles',
        name: 'Roles',
        component: () => import(/* webpackChunkName: "roles" */ '../views/roles/indexView.vue')
      }
    ]
  }
] as RouteRecordRaw[];

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export function setupRouter(app: App<Element>) {
  app.use(router)
}
